<% section_markup = capture do %>
  <% if @title.present? %>
    <%= polaris_box(
      padding_block_start: "3",
      padding_inline_start: "4",
      padding_block_end: "1",
      padding_inline_end: "4"
    ) do %>
      <%= polaris_text(as: :p, variant: :headingXs) do %>
        <%= @title %>
      <% end %>
    <% end %>
  <% end %>
  <%= polaris_box(
    padding: "2",
    padding_block_start: @title.present? ? "0" : (@multiple_sections ? "0" : "2"),
  ) do %>
    <%= polaris_vertical_stack(as: :ul, gap: "1") do %>
      <% if items.present? %>
        <% items.each do |item| %>
          <%= item %>
        <% end %>
      <% else %>
        <%= content %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

<% if @multiple_sections %>
  <%= polaris_box(
    as: :li,
    border_color: "border-subdued",
    border_block_start_width: (@position != 1) ? "1" : nil,
    padding_block_start: @title.blank? ? "2" : nil
  ) do %>
    <%= section_markup %>
  <% end %>
<% else%>
  <%= section_markup %>
<% end %>
